﻿@using rentit03_client.Models
@{
    var total = 0;
    ViewBag.Title = "Shopping Cart";
}
<div class="help-block">
    The table shows the current movies in your shopping cart. Click on <em>Check out</em>
    to purchase them.</div>
<table class="table table-striped">
    <thead>
        <tr>
            <th>
                Movie
            </th>
            <th>
                Resolution
            </th>
            <th>
                Format
            </th>
            <th>
                Price
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (MovieObj movie in ViewBag.Cart)
        {
            VersionObj version = movie.Versions.First();
            total += version.Price;
            <tr>
                <td>
                    <h6>
                        @movie.Title (@movie.Year)</h6>
                </td>
                <td>
                    @version.Resolution
                </td>
                <td>
                    @version.Format
                </td>
                <td style="text-align: right">
                    @version.Price
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <td>
            </td>
            <td>
            </td>
            <td>
            </td>
            <td style="text-align: right">
                @total
            </td>
        </tr>
    </tfoot>
</table>
@if (ViewBag.Cart.Count > 0)
{
    <div class="form-actions">
        @Html.ActionLink("Check out", "CheckOut", "Cart", new { }, new { @class = "btn btn-success" })
    </div>
}